```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MySQL索引结构深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            background-color: #f9fafb;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb 0%, #4a6cf7 100%);
            color: white;
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .index-icon {
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            margin-right: 16px;
        }
        h1, h2, h3 {
            font-family: 'Noto Serif SC', serif;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.9;
            margin-right: 0.1em;
            font-weight: bold;
            color: #4a6cf7;
        }
    </style>
</head>
<body>
    <div class="hero py-20 px-6 md:px-10 lg:px-20">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">MySQL索引结构深度解析</h1>
            <p class="text-xl opacity-90 mb-8">探索B+树及其他索引类型的内部实现原理</p>
            <div class="w-24 h-1 bg-white opacity-50 mx-auto mb-8"></div>
            <p class="text-lg max-w-3xl mx-auto drop-cap">在数据库系统中，索引是提高查询性能的关键组件。MySQL采用多种索引结构来优化不同类型的数据检索操作，其中B+树索引是最常见且重要的索引类型之一。了解这些索引的内部结构和工作原理，对于数据库性能优化至关重要。</p>
        </div>
    </div>

    <div class="max-w-5xl mx-auto px-6 md:px-10 lg:px-20 py-16">
        <div class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center">索引类型比较</h2>
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                <div class="card bg-white p-6 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="index-icon bg-blue-100 text-blue-600">
                            <i class="fas fa-sitemap text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">B+树索引</h3>
                    </div>
                    <p class="text-gray-600">叶子节点存储索引键值和数据行指针，支持高效的范围查询和排序操作。</p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <span class="text-sm font-medium text-blue-600">适用场景</span>
                        <p class="text-sm text-gray-500 mt-1">范围查询、排序操作、等值查询</p>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="index-icon bg-purple-100 text-purple-600">
                            <i class="fas fa-search text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">全文索引</h3>
                    </div>
                    <p class="text-gray-600">存储文档ID和关键词位置，专门用于全文搜索场景。</p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <span class="text-sm font-medium text-purple-600">适用场景</span>
                        <p class="text-sm text-gray-500 mt-1">全文搜索、文本匹配</p>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="index-icon bg-green-100 text-green-600">
                            <i class="fas fa-map-marked-alt text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">空间索引</h3>
                    </div>
                    <p class="text-gray-600">存储空间对象和位置，用于处理地理坐标或几何形状数据。</p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <span class="text-sm font-medium text-green-600">适用场景</span>
                        <p class="text-sm text-gray-500 mt-1">地理数据、GIS应用</p>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="index-icon bg-yellow-100 text-yellow-600">
                            <i class="fas fa-bolt text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">哈希索引</h3>
                    </div>
                    <p class="text-gray-600">使用哈希桶存储数据行指针，提供极快的等值查询性能。</p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <span class="text-sm font-medium text-yellow-600">适用场景</span>
                        <p class="text-sm text-gray-500 mt-1">等值查询、键值存储</p>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="index-icon bg-red-100 text-red-600">
                            <i class="fas fa-layer-group text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">聚集索引</h3>
                    </div>
                    <p class="text-gray-600">叶子节点存储完整数据行，避免了二次查询的开销。</p>
                    <div class="mt-4 pt-4 border-t border-gray-100">
                        <span class="text-sm font-medium text-red-600">适用场景</span>
                        <p class="text-sm text-gray-500 mt-1">主键查询、频繁访问的全行数据</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="mb-16">
            <h2 class="text-3xl font-bold mb-6">B+树索引详解</h2>
            <div class="bg-white rounded-xl p-6 md:p-8 shadow-sm">
                <div class="flex flex-col md:flex-row">
                    <div class="md:w-1/2 pr-0 md:pr-6">
                        <h3 class="text-xl font-bold mb-4 text-blue-600">数据结构</h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>叶子节点存储索引键值和数据行指针</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>所有叶子节点通过链表连接，支持高效范围查询</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>非叶子节点只存储键值和子节点指针</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>树的高度通常保持3-4层，保证查询效率</span>
                            </li>
                        </ul>

                        <h3 class="text-xl font-bold mt-8 mb-4 text-blue-600">性能优势</h3>
                        <div class="grid grid-cols-2 gap-4">
                            <div class="bg-blue-50 p-3 rounded-lg">
                                <div class="text-blue-600 mb-1"><i class="fas fa-search mr-1"></i> 查询效率</div>
                                <div class="text-sm text-gray-600">O(logN)时间复杂度</div>
                            </div>
                            <div class="bg-blue-50 p-3 rounded-lg">
                                <div class="text-blue-600 mb-1"><i class="fas fa-sort-amount-up mr-1"></i> 排序性能</div>
                                <div class="text-sm text-gray-600">天然有序结构</div>
                            </div>
                            <div class="bg-blue-50 p-3 rounded-lg">
                                <div class="text-blue-600 mb-1"><i class="fas fa-expand-alt mr-1"></i> 范围查询</div>
                                <div class="text-sm text-gray-600">通过叶子链表高效支持</div>
                            </div>
                            <div class="bg-blue-50 p-3 rounded-lg">
                                <div class="text-blue-600 mb-1"><i class="fas fa-database mr-1"></i> 磁盘IO</div>
                                <div class="text-sm text-gray-600">减少磁盘访问次数</div>
                            </div>
                        </div>
                    </div>
                    <div class="md:w-1/2 mt-6 md:mt-0">
                        <div class="mermaid">
                            graph TD
                            A[根节点] --> B[非叶子节点]
                            A --> C[非叶子节点]
                            B --> D[叶子节点: 键值+指针]
                            B --> E[叶子节点: 键值+指针]
                            C --> F[叶子节点: 键值+指针]
                            C --> G[叶子节点: 键值+指针]
                            D -->|双向链表| E
                            E -->|双向链表| F
                            F -->|双向链表| G
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="mb-16">
            <h2 class="text-3xl font-bold mb-6">索引类型比较表</h2>
            <div class="bg-white rounded-xl overflow-hidden shadow-sm">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">索引类型</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">叶子节点存储内容</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">查询效率</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">是否有序</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">适用场景</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap font-medium text-blue-600">B+树索引</td>
                            <td class="px-6 py-4 whitespace-nowrap">键值+数据行指针</td>
                            <td class="px-6 py-4 whitespace-nowrap">O(logN)</td>
                            <td class="px-6 py-4 whitespace-nowrap"><i class="fas fa-check text-green-500"></i></td>
                            <td class="px-6 py-4">范围查询、排序、等值查询</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap font-medium text-purple-600">全文索引</td>
                            <td class="px-6 py-4 whitespace-nowrap">文档ID+关键词位置</td>
                            <td class="px-6 py-4 whitespace-nowrap">O(logN)</td>
                            <td class="px-6 py-4 whitespace-nowrap"><i class="fas fa-times text-gray-400"></i></td>
                            <td class="px-6 py-4">全文搜索、文本匹配</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap font-medium text-green-600">空间索引</td>
                            <td class="px-6 py-4 whitespace-nowrap">空间对象+位置</td>
                            <td class="px-6 py-4 whitespace-nowrap">O(logN)</td>
                            <td class="px-6 py-4 whitespace-nowrap"><i class="fas fa-check text-green-500"></i></td>
                            <td class="px-6 py-4">地理数据、GIS应用</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap font-medium text-yellow-600">哈希索引</td>
                            <td class="px-6 py-4 whitespace-nowrap">哈希桶+数据行指针</td>
                            <td class="px-6 py-4 whitespace-nowrap">O(1)</td>
                            <td class="px-6 py-4 whitespace-nowrap"><i class="fas fa-times text-gray-400"></i></td>
                            <td class="px-6 py-4">等值查询、键值存储</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap font-medium text-red-600">聚集索引</td>
                            <td class="px-6 py-4 whitespace-nowrap">完整数据行</td>
                            <td class="px-6 py-4 whitespace-nowrap">O(logN)</td>
                            <td class="px-6 py-4 whitespace-nowrap"><i class="fas fa-check text-green-500"></i></td>
                            <td class="px-6 py-4">主键查询、全行数据访问</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class="mb-16">
            <h2 class="text-3xl font-bold mb-6">索引选择指南</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-xl font-bold mb-4 flex items-center text-blue-600">
                        <i class="fas fa-lightbulb mr-2"></i> 何时使用B+树索引
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-blue-500 mr-2">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p>需要支持范围查询（>, <, BETWEEN, LIKE 'prefix%'）</p>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-blue-500 mr-2">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p>查询需要排序或分组操作（ORDER BY, GROUP BY）</p>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-blue-500 mr-2">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p>高基数（高唯一性）的列</p>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-blue-500 mr-2">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p>频繁作为WHERE条件的列</p>
                        </li>
                    </ul>
                </div>

                <div class="bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-xl font-bold mb-4 flex items-center text-red-600">
                        <i class="fas fa-exclamation-triangle mr-2"></i> 何时避免索引
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-red-500 mr-2">
                                <i class="fas fa-times-circle"></i>
                            </div>
                            <p>频繁更新的列（索引维护开销高）</p>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-red-500 mr-2">
                                <i class="fas fa-times-circle"></i>
                            </div>
                            <p>低基数（低唯一性）的列（如性别、布尔值）</p>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-red-500 mr-2">
                                <i class="fas fa-times-circle"></i>
                            </div>
                            <p>小表（全表扫描可能更快）</p>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 h-5 w-5 text-red-500 mr-2">
                                <i class="fas fa-times-circle"></i>
                            </div>
                            <p>使用函数或计算的列（除非创建函数索引）</p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="mb-16">
            <h2 class="text-3xl font-bold mb-6">索引优化实践</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4 text-purple-600">复合索引设计</h3>
                    <div class="bg-white p-6 rounded-xl shadow-sm">
                        <div class="mermaid">
                            graph LR
                            A[最左前缀原则] --> B[索引第一列最重要]
                            A --> C[后续列顺序影响查询]
                            A --> D[避免重复索引]
                            B --> E[WHERE条件中的第一列]
                            C --> F[范围查询后的列无效]
                        </div>
                        <div class="mt-4 text-sm text-gray-600">
                            <p class="font-medium">示例：INDEX(a,b,c)</p>
                            <p>有效查询：WHERE a=1 AND b=2 AND c=3</p>
                            <p>部分有效：WHERE a=1 AND b>2 (不使用c)</p>
                            <p>无效查询：WHERE b=2 AND c=3 (不使用a)</p>
                        </div>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-xl font-bold mb-4 text-green-600">覆盖索引优化</h3>
                    <div class="bg-white p-6 rounded-xl shadow-sm">
                        <div class="flex items-start mb-4">
                            <div class="mr-4 text-green-500">
                                <i class="fas fa-check-circle text-2xl"></i>
                            </div>
                            <div>
                                <p class="font-medium">包含查询所需的所有列</p>
                                <p class="text-sm text-gray-600">避免回表操作，直接从索引获取数据</p>
                            </div>
                        </div>
                        <div class="mermaid">
                            pie
                            title 查询性能对比
                            "索引覆盖" : 70
                            "回表查询" : 30
                        </div>
                        <div class="mt-4 text-sm">
                            <p><span class="font-medium">示例：</span>SELECT a,b FROM table WHERE a=1</p>
                            <p><span class="font-medium">优化：</span>创建INDEX(a,b)而非仅INDEX(a)</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeCSS: `
                .node rect {
                    fill: #fff;
                    stroke: #4a6cf7;
                    stroke-width: 2px;
                }
                .node text {
                    font-family: 'Noto Sans SC', sans-serif;
                }
                .edgePath path {
                    stroke: #4a6cf7;
                    stroke-width: 2px;
                }
            `
        });
    </script>
</body>
</html>
```